nginx-ingress examples¶
rewrites
https://github.com/nginxinc/kubernetes-ingress/tree/v1.8.1/examples/rewrites
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: cafe-ingress annotations: nginx.org/rewrites: "serviceName=tea-svc rewrite=/;serviceName=coffee-svc rewrite=/beans/" spec: rules: - host: cafe.example.com http: paths: - path: /tea/ backend: serviceName: tea-svc servicePort: 80 - path: /coffee/ backend: serviceName: coffee-svc servicePort: 80rewrites
https://github.com/nginxinc/kubernetes-ingress/tree/v1.8.1/examples-of-custom-resources/rewrites
apiVersion: k8s.nginx.org/v1 kind: VirtualServer metadata: name: cafe spec: host: cafe.example.com upstreams: - name: tea service: tea-svc port: 80 - name: coffee service: coffee-svc port: 80 routes: - path: /tea/ action: proxy: upstream: tea rewritePath: / - path: /coffee action: proxy: upstream: coffee rewritePath: /beanssnippets
apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: cafe-ingress-with-snippets annotations: nginx.org/server-snippets: | location / { return 302 /coffee; } nginx.org/location-snippets: | add_header my-test-header test-value; spec: rules: - host: cafe.example.com http: paths: - path: /tea backend: serviceName: tea-svc servicePort: 80 - path: /coffee backend: serviceName: coffee-svc servicePort: 80